<?php
namespace app\common\service;

use think\Page;
use app\common\logic\wechat\WechatUtil;
use think\facade\Db;

/**
 * Class GetIndexChart
 * @package app\common\service
 * 获取首页柱形图产品
 */
class GetIndexChart extends Base {
    static $AUTH_CHECK = false; //默认必须登录

    public function index(){

        $lists = Db::name('goods')
            ->where(['is_on_sale'=>1,'show_index'=>1])
            ->field('goods_id,goods_name,original_img,market_price,shop_price,now_price')
            ->limit(3)
            ->select();
        if($lists){
            foreach($lists as $k=>$v){
                $goods_name = $v['goods_name'];
                if(mb_strlen($v['goods_name'])>5){
                    $goods_name = mb_substr($v['goods_name'],0,5).'...';
                }
                $lists[$k]['goods_name'] = $goods_name;
            }
        }
        $result = [
            'status' => true,
            'msg' => '',
            'data' => $lists,
        ];
        return $result;
    }


}
